<?php
/**
* @version		$Id: view.html.php 10214 2008-04-19 08:59:04Z eddieajau $
* @package		Joomla
* @subpackage	Media
* @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );

jimport( 'joomla.application.component.view');

/**
 * HTML View class for the WebLinks component
 *
 * @static
 * @package		Joomla
 * @subpackage	Media
 * @since 1.0
 */
class MediaViewJImages extends JView
{
	function display($tpl = null)
	{
		global $mainframe;

		$config =& JComponentHelper::getParams('com_media');

		$app = JFactory::getApplication();
		$append = '';
		if($app->getClientId() == 1) $append = 'administrator/';

		JHTML::_('script'    , 'popup-jimagemanager.js', $append .'components/com_media/assets/');
		JHTML::_('stylesheet', 'popup-jimagemanager.css', $append .'components/com_media/assets/');
		if ($config->get('enable_flash', 1)) {
			JHTML::_('behavior.uploader', 'file-upload', array('onAllComplete' => 'function(){ JImageManager.refreshFrame(); }'));
		}

		// Adding script and css for acordion
		$document = &JFactory::getDocument();
		
		$document->addStyleSheet('components/com_media/assets/mediamanagerstudio.css');
		

		$document->addScriptDeclaration("
			window.addEvent('domready', function(){	
			
			var color = [0, 0, 0];
				var updateColor = function(){
				$('setColor').setStyle('color', color).setHTML(color.rgbToHex());

			};

		var mySlide = new Slider($('area'), $('knob'), {
			steps: 255,	
			onChange: function(step){
				$('upd').setHTML(step);
				color[0] = step;
				updateColor();
				window.document.imageForm.r.value = step;
				
				
			}
		 
		}).set(0);


		var mySlide2 = new Slider($('area2'), $('knob2'), {
			steps: 255,	
			onChange: function(step){
				$('upd2').setHTML(step);
						color[1] = step;
				updateColor();
			window.document.imageForm.g.value = step;
				
			}
		 
		}).set(0);
		 

		var mySlide3 = new Slider($('area3'), $('knob3'), {	
			steps: 255,	
				onChange: function(step){
				$('upd3').setHTML(step);
						color[2] = step;
				updateColor();
				window.document.imageForm.b.value = step;
			
			}
		}).set(0);
		var mySlide4= new Slider($('area4'), $('knob4'), {	
			steps: 100,	
				onChange: function(step){
				$('upd4').setHTML(step);
				window.document.imageForm.bright.value = step;
			}
		}).set(0);

		var mySlide5= new Slider($('area5'), $('knob5'), {	
			steps: 100,	
				onChange: function(step){
				$('upd5').setHTML(step);
				window.document.imageForm.contrast.value = step;
			}
		}).set(0);
		var mySlide6= new Slider($('area6'), $('knob6'), {	
			steps: 8,	
				onChange: function(step){
				$('upd6').setHTML(step);
				window.document.imageForm.opacity.value = step;
			}
		}).set(0);
		var mySlide7= new Slider($('area7'), $('knob7'), {	
			steps: 100,	
				onChange: function(step){
				$('upd7').setHTML(step);
				window.document.imageForm.quality.value = step;
			}
		}).set(0);



		});

			"); 
	
		$document->addScriptDeclaration("
		window.addEvent('domready', function(){	
			var stretchers = document.getElementsByClassName('box');
			var toggles = document.getElementsByClassName('tab');
			var myAccordion = new Accordion(
				toggles, stretchers, {opacity: false, height: true, duration: 600}
			);
		});" );

		$document->addScriptDeclaration("
			function resize_color(index)
			{
				if (index == 5){
					document.imageForm.resizecolor.disabled = false;
				}
				else {
					document.imageForm.resizecolor.disabled = true;
					document.imageForm.resizecolor.value = '';
				}
			}
		");

		/*
		 * Display form for FTP credentials?
		 * Don't set them here, as there are other functions called before this one if there is any file write operation
		 */
		jimport('joomla.client.helper');
		$ftp = !JClientHelper::hasCredentials('ftp');

		$this->assignRef( 'session',	JFactory::getSession());
		$this->assignRef( 'config',		$config);
		$this->assignRef( 'state',		$this->get('state'));
		$this->assignRef( 'folderList',	$this->get('folderList'));
		$this->assign('require_ftp', $ftp);

		parent::display($tpl);
	}
}
